package org.jetty.start.up;

import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.resource.ResourceCollection;
import org.eclipse.jetty.webapp.WebAppContext;

public class StartJetty
{
	public static void main(final String[] aArgs) throws Exception
	{
		final Server server = new Server(8080);

		server.setHandler(createWebAppContext());

		server.start();
		System.out.println("Server Started...");
//		openAppInBrowser();
//		System.out.println("Home Page Opened");
		server.join();
	}

	private static WebAppContext createWebAppContext()
	{
		final WebAppContext context = new WebAppContext();
		context.setContextPath("/");
		context.setBaseResource(new ResourceCollection(new String[] { "./webapp" }));
		return context;
	}
	
	private static void openAppInBrowser()
	{
		try
		{
			String[] commandLine = { "C:\\Program Files\\Internet Explorer\\iexplore.exe", "http://localhost:8080/bseIndia/googleXMLFeed" };
			Runtime.getRuntime().exec(commandLine);
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}
}